/* 
 * Copyright (c) 2019, CENTRIN.CIYUN.LTD. All rights reserved.
 */
package com.cory.boot.domain.chart;

import java.util.Arrays;
import java.util.List;

import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;

/**
 * 表图数据
 * @author xiongcong
 * @date 2019-04-09
 */
@Getter
@Setter
@SuppressWarnings({"unchecked", "rawtypes"})
public class Data<T> {
    private List data = Lists.newArrayList();
    
    public T data(Object... values) {
        if ((values == null) || (values.length == 0)) {
            return (T)this;
        }
        
        if (data == null) {
            data = Lists.newArrayList();
        }

        data.addAll(Arrays.asList(values));
        return (T)this;
    }
    
    public T addFirst(Object value) {
        if (value == null) {
            return (T)this;
        }
        
        if (data == null) {
            data = Lists.newArrayList();
        }

        data.add(0, value);
        return (T)this;
    }
    
    public T addData(int index, Object value) {
        if (value == null) {
            return (T)this;
        }
        
        if (data == null) {
            data = Lists.newArrayList();
        }

        data.add(index, value);
        return (T)this;
    }
}
